Fixed an issue where multiple Tools with FunctionDeclarations#56
Conversation
…nerated when multiple AIFunction were defined, causing Gemini to return 400. Now only a single Tool is generated.
WalkthroughThe code refactors the way AI function tools are assigned within the Changes
Estimated code review effort2 (10–30 minutes) Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/GenerativeAI.Microsoft/Extensions/MicrosoftExtensions.cs (1)
56-65: Fix addresses the issue correctly, but remove redundant ToList().The logic correctly creates a single Tool containing all function declarations, which should resolve the Gemini 400 error. However, there's a redundant
ToList()call sincefunctionDeclarationsis already aList<FunctionDeclaration>.Apply this diff to remove the unnecessary list copy:
- FunctionDeclarations = functionDeclarations.ToList() + FunctionDeclarations = functionDeclarations
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/GenerativeAI.Microsoft/Extensions/MicrosoftExtensions.cs(1 hunks)
🔇 Additional comments (1)
src/GenerativeAI.Microsoft/Extensions/MicrosoftExtensions.cs (1)
47-54: LGTM: Clean transformation logic.The code correctly transforms AIFunction objects into FunctionDeclaration objects with proper null handling and clear variable naming.
Fixed an issue where multiple Tools with FunctionDeclarations generated when multiple AIFunction were defined, causing Gemini to return 400.
Now only a single Tool is generated.
Summary by CodeRabbit